VERSION 5.00
Begin VB.Form frmChange 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Change password"
   ClientHeight    =   3045
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   4845
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   3045
   ScaleWidth      =   4845
   Begin VB.CommandButton cmdCancel 
      Caption         =   "&Cancel"
      Height          =   495
      Left            =   2760
      TabIndex        =   9
      Top             =   2280
      Width           =   1575
   End
   Begin VB.CommandButton cmdOK 
      Caption         =   "&OK"
      Height          =   495
      Left            =   960
      TabIndex        =   8
      Top             =   2280
      Width           =   1455
   End
   Begin VB.TextBox txtConfirm 
      Height          =   375
      IMEMode         =   3  'DISABLE
      Left            =   2880
      PasswordChar    =   "*"
      TabIndex        =   7
      Top             =   1560
      Width           =   1575
   End
   Begin VB.TextBox txtNewpass 
      Height          =   375
      IMEMode         =   3  'DISABLE
      Left            =   2880
      PasswordChar    =   "*"
      TabIndex        =   6
      Top             =   1080
      Width           =   1575
   End
   Begin VB.TextBox txtOldpass 
      Height          =   375
      IMEMode         =   3  'DISABLE
      Left            =   2880
      PasswordChar    =   "*"
      TabIndex        =   5
      Top             =   600
      Width           =   1575
   End
   Begin VB.TextBox txtUser 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   405
      Left            =   2880
      TabIndex        =   1
      Top             =   120
      Width           =   1575
   End
   Begin VB.Label Label4 
      BackStyle       =   0  'Transparent
      Caption         =   "Confirm new passowrd:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   120
      TabIndex        =   4
      Top             =   1560
      Width           =   2535
   End
   Begin VB.Label Label3 
      BackStyle       =   0  'Transparent
      Caption         =   "New password:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   120
      TabIndex        =   3
      Top             =   1080
      Width           =   2175
   End
   Begin VB.Label Label2 
      BackStyle       =   0  'Transparent
      Caption         =   "Old password:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   120
      TabIndex        =   2
      Top             =   600
      Width           =   1935
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      Caption         =   "User name:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   1335
   End
End
Attribute VB_Name = "frmChange"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdCancel_Click()
Unload Me
End Sub

Private Sub cmdOK_Click()
Dim db As ADODB.Connection
Dim rst As ADODB.Recordset
Dim ok1 As Boolean
Dim ok2 As Boolean

Set db = New ADODB.Connection
db.Provider = "microsoft.jet.oledb.4.0"
db.Open App.Path & "\bo.mdb"
Set rst = New ADODB.Recordset
rst.Open "tbl_pass", db, adOpenDynamic, adLockOptimistic

ok1 = False
With rst
    .MoveFirst
    Do Until .EOF
        If ![UserName] = Me![txtUser] Then ok1 = True
            If ok1 = True Then
                If ![pass] = Me![txtOldpass] Then
                    If Me![txtNewpass] = Me![txtConfirm] Then
                        ![pass] = Me![txtNewpass]
                        .Update
                        ok2 = True
                        MsgBox "Changed"
                        Exit Do
                    Else
                        MsgBox "New password and confirm are not the same"
                        [txtNewpass].SetFocus
                        Exit Do
                    End If
                Else
                    MsgBox "Old password incorrect"
                    [txtOldpass].SetFocus
                End If
            End If
        .MoveNext
    Loop
    If ok1 = False Then
        MsgBox "User not found"
        [txtUser].SetFocus
    End If
End With
If ok2 = True Then Unload Me

End Sub

Private Sub Form_Load()
Me.Top = Screen.Height / 2 - (Me.Height / 1.5)
    Me.Left = Screen.Width / 2 - (Me.Width / 2)
End Sub
